/**
 * @public
 * @constructor
 * @param <String> source
 */

function XMLParser(source)
{
	this.init(source);
}
var $p = (Type.extend(XMLParser, SyntaxParser)).prototype;

/*
(<!\[CDATA\[\s*.*\s*\]\]>)
| (<!--\s*.*\s*?-->)
| (<)*(\w+)*\s*(\w+)\s*=\s*(".*?"|'.*?'|\w+)(/*>)*
| (</?)(.*?)(/?>)
 * partitions Regexp.
 * @protected
 */
var idPattern = "[\\w_][\\w\\d-_\\.]*"
, namePattern = "(?:" + idPattern + "[:])?" + idPattern
, stringPattern = '"(?:\\\\.|[^"\\n\\r])*"|' + "'(?:\\\\.|[^'\\n\\r])*'"
, ltgtPattern = "^<|>$"
, attributePattern = new RegExp("(" + namePattern + ")(\\s*=\\s*)(" + stringPattern + ")", "g")
, attributeReplacer = "<span class='xidea-syntax-xml-attribute'>$1</span>$2<span class='xidea-syntax-xml-string'>$3</span>";
/**
 * partitions Regexp for xml
 * @protected
 * @type Object
 * @id XMLParser.prototype.partitionerMap
 */
$p.setPartitionerMap(
{
	"xml-cdata" : "<\\!\\[[\\w]*\\[[^\\]]|\\][^\\]]|\\]\\][^>]\\]\\]>"	//cdata
	, "xml-processor" : "<\\?(?:[^\\?]|\\?[^>])*\\?>"					//processor
	, "xml-comment" : "<!--(?:[^-]|-[^-])*-->"							//comment
	, "xml-begin" : "<" + idPattern + "[^<>]*>"							//begin tag
	, "xml-end" : "</" + namePattern + ">"								//end tag
});

/**
 * render map for xml
 * @protected
 * @type Object
 * @id XMLParser.prototype.renderMap
 */
$p.setRenderMap(
{
	"xml-begin": $p.buildRender(attributePattern, attributeReplacer)
});

/**
 * private
 */
$p.defaultType = "xml-text";

$p.guessType = function(p)
{
	for (var n in this.partitionerMap)
	{
		if (this.partitionerMap[n].test(p))
		{
			return n;
		}
	}
	return this.defaultType;
};
$p = null;